import 'package:cbec_app/components/base/base_function.dart';
import 'package:cbec_app/components/base/base_tab_nav_item.dart';
import 'package:cbec_app/components/decoration/elevator_nav_item.dart';
import 'package:cbec_app/routes/routes.dart';
import 'package:cbec_app/utils/ThemeConfig.dart';
import 'package:cbec_app/utils/Tools.dart';
import 'package:cbec_app/utils/logger.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

///店铺装修-电梯导航
class DecorationElevatorNav extends StatefulWidget {
  ///电梯导航配置
  final Map<String, dynamic> info;

  const DecorationElevatorNav({super.key, required this.info});

  @override
  State<StatefulWidget> createState() {
    return _DecorationElevatorNavState();
  }
}

class _DecorationElevatorNavState extends State<DecorationElevatorNav> {
  @override
  Widget build(BuildContext context) {
    return getBoxStyle();
  }

  ///获取容器样式
  Widget getBoxStyle() {
    switch (widget.info['slide_setting']) {
      case 0: //下拉展示
        return Container(
          padding: EdgeInsets.only(left: 10.w, right: 10.w),
          color: Tools.fromHex(widget.info['background_color']),
        );
      case 1: //横向滚动
      default:
        return Container(
          padding: EdgeInsets.only(left: 10.w, right: 10.w),
          color: Tools.fromHex(widget.info['background_color']),
          child: SingleChildScrollView(
            scrollDirection: Axis.horizontal,
            child: Row(
              children: createList(),
            ),
          ),
        );
    }
  }
  ///生成导航列表
  List<Widget> createList() {
    List<Widget> arr = [];
    for (var i = 0; i < widget.info['sub_entry'].length; i++) {
      arr.add(ElevatorNavItem(
        info: widget.info,
        item: widget.info['sub_entry'][i],
        index: i,
        curIndex: 0,
        callback: () {
         Tools.jumpPage(widget.info['sub_entry'][i]);
        },
      ));
    }
    return arr;
  }
}
